


/* DID as in  Callaway & Sant'Anna */ 


use "G:\Data\Workdata\707677\Common\01Data\02STATA\panel_iv", replace

cd G:\Data\Workdata\707677\FKYY7677\Debt_relief\Statafiles\Outputs\Revision\Graphs\Standard-Event-Study



keep if time>-5 & time<17

tab aar, gen(yeardum)											/* Year dummies */

tab time if (time>-5 & time<17), gen(timedum)					/* Time dummies */



/* Create variables for difference-in-difference setup */


gen treated=granted

gen after=0

replace after=1 if time>0

gen interaction=treated*after





foreach i of num 1/21 {											/* Time dummies intearacted with treatment */
	
gen interaction`i'=timedum`i'*treated	
	
	
}




destring pnr, replace

replace time=time+10


gen treatment_year=0
replace treatment_year=10 if granted==1



/* Earned Income */



local depvar1 "erhvervsindk_real"




foreach var of varlist `depvar1'{


gen outcome=`var'



gen pre=0

gen post=0

replace pre=1 if (outcome~=. & time<1)

replace post=1 if (outcome~=. & time>0)



gen zero_lead1=0



csdid outcome i.pyear, long2 ivar(pnr) time(time) gvar(treatment_year) 

estat event, window(-4,16)


eststo callaway

coefplot callaway, vertical
xtset pnr aar





xtreg outcome interaction1 interaction2 interaction3 zero_lead1 interaction5-interaction21 yeardum* timedum*  , cluster(pnr) fe
eststo standard







#delimit ; 

coefplot (standard, mcolor(maroon) ciopts(color(maroon))) (callaway,  mcolor(blue) ciopts(color(blue)) rename(t_6_9=interaction1 t_7_9=interaction2 t_8_9=interaction3 t_9_10=interaction5 t_9_11=interaction6 t_9_12=interaction7 t_9_13=interaction8 t_9_14=interaction9 t_9_15=interaction10 ///
t_9_16=interaction11 t_9_17=interaction12 t_9_18=interaction13 t_9_19=interaction14 t_9_20=interaction15 t_9_21=interaction16 ///
t_9_22=interaction17 t_9_23=interaction18 t_9_24=interaction19 t_9_25=interaction20 t_9_26=interaction21 )),  omitted  vertical drop(yeardum* timedum* _cons) 



title("`var'")






xlabel(1 "-4" 2 " " 3 "-2" 4 " " 5 "0" 6 " " 7 "2" 8 " " 9 "4" 10 " " 11 "6" 12 " " 13 "8" 

14 " " 15 "10" 16 " " 17 "12" 18 " " 19 "14" 20 " " 21 "16", angle(0) nogrid labsize(medsmall))


ylabel(0 "0" 10000 "10" 20000 "20" 30000 "30" 40000 "40",nogrid angle(0) labsize(medsmall))




yscale(titlegap(*-3))


yline(0, lcolor(black))

xline(4, lcolor(black) lpattern(dash))

ytitle("Earned Income", size(medium))

xtitle("Years", size(medsmall))

title("")


graphregion(fcolor(white)) bgcolor(white) scheme(s1color)

name(earnings, replace)


;


#delimit cr



drop outcome zero_lead1 pre post 



}

* Employment



local depvar1 "employed_pstill"




foreach var of varlist `depvar1'{


gen outcome=`var'



gen pre=0

gen post=0

replace pre=1 if (outcome~=. & time<1)

replace post=1 if (outcome~=. & time>0)



gen zero_lead1=0



csdid outcome i.pyear, long2 ivar(pnr) time(time) gvar(treatment_year) 

estat event, window(-4,16)


eststo callaway

coefplot callaway, vertical
xtset pnr aar





xtreg outcome interaction1 interaction2 interaction3 zero_lead1 interaction5-interaction21 yeardum* timedum*  , cluster(pnr) fe
eststo standard







#delimit ; 

coefplot (standard, mcolor(maroon) ciopts(color(maroon))) (callaway,  mcolor(blue) ciopts(color(blue)) rename(t_6_9=interaction1 t_7_9=interaction2 t_8_9=interaction3 t_9_10=interaction5 t_9_11=interaction6 t_9_12=interaction7 t_9_13=interaction8 t_9_14=interaction9 t_9_15=interaction10 ///
t_9_16=interaction11 t_9_17=interaction12 t_9_18=interaction13 t_9_19=interaction14 t_9_20=interaction15 t_9_21=interaction16 ///
t_9_22=interaction17 t_9_23=interaction18 t_9_24=interaction19 t_9_25=interaction20 t_9_26=interaction21 )),  omitted  vertical drop(yeardum* timedum* _cons) 



title("`var'")






xlabel(1 "-4" 2 " " 3 "-2" 4 " " 5 "0" 6 " " 7 "2" 8 " " 9 "4" 10 " " 11 "6" 12 " " 13 "8" 

14 " " 15 "10" 16 " " 17 "12" 18 " " 19 "14" 20 " " 21 "16", angle(0) nogrid labsize(medsmall))



ylabel(0 "0%" 0.025 "2.5%" 0.05 "5.0%" 0.075 "7.5%",nogrid angle(0) labsize(medsmall))





yscale(titlegap(*-3))


yline(0, lcolor(black))

xline(4, lcolor(black) lpattern(dash))

ytitle("Employment", size(medium))

xtitle("Years", size(medsmall))

title("")


graphregion(fcolor(white)) bgcolor(white) scheme(s1color)

name(employment, replace)


;


#delimit cr




drop outcome zero_lead1 pre post 



}

* Assets

	local depvar1 "aktiv_real"




foreach var of varlist `depvar1'{


gen outcome=`var'



gen pre=0

gen post=0

replace pre=1 if (outcome~=. & time<1)

replace post=1 if (outcome~=. & time>0)



gen zero_lead1=0



csdid outcome i.pyear, long2 ivar(pnr) time(time) gvar(treatment_year) 

estat event, window(-4,16)


eststo callaway

coefplot callaway, vertical
xtset pnr aar





xtreg outcome interaction1 interaction2 interaction3 zero_lead1 interaction5-interaction21 yeardum* timedum*  , cluster(pnr) fe
eststo standard








#delimit ; 

coefplot (standard, mcolor(maroon) ciopts(color(maroon))) (callaway,  mcolor(blue) ciopts(color(blue)) rename(t_6_9=interaction1 t_7_9=interaction2 t_8_9=interaction3 t_9_10=interaction5 t_9_11=interaction6 t_9_12=interaction7 t_9_13=interaction8 t_9_14=interaction9 t_9_15=interaction10 ///
t_9_16=interaction11 t_9_17=interaction12 t_9_18=interaction13 t_9_19=interaction14 t_9_20=interaction15 t_9_21=interaction16 ///
t_9_22=interaction17 t_9_23=interaction18 t_9_24=interaction19 t_9_25=interaction20 t_9_26=interaction21 )),  omitted  vertical drop(yeardum* timedum* _cons) 



title("`var'")






xlabel(1 "-4" 2 " " 3 "-2" 4 " " 5 "0" 6 " " 7 "2" 8 " " 9 "4" 10 " " 11 "6" 12 " " 13 "8" 

14 " " 15 "10" 16 " " 17 "12" 18 " " 19 "14" 20 " " 21 "16", angle(0) nogrid labsize(medsmall))


ylabel(0 "0" 100000 "100" 200000 "200" 300000 "300",nogrid angle(0) labsize(medsmall))






yscale(titlegap(*-3))


yline(0, lcolor(black))

xline(4, lcolor(black) lpattern(dash))

ytitle("Assets", size(medium))

xtitle("Years", size(medsmall))

title("")


graphregion(fcolor(white)) bgcolor(white) scheme(s1color)

name(assets, replace)


;


#delimit cr




drop outcome zero_lead1 pre post 



}





* Wealth


local depvar1 "formue_real"




foreach var of varlist `depvar1'{


gen outcome=`var'



gen pre=0

gen post=0

replace pre=1 if (outcome~=. & time<1)

replace post=1 if (outcome~=. & time>0)



gen zero_lead1=0



csdid outcome i.pyear , long2 ivar(pnr) time(time) gvar(treatment_year) 

estat event, window(-4,16)


eststo callaway

coefplot callaway, vertical
xtset pnr aar





xtreg outcome interaction1 interaction2 interaction3 zero_lead1 interaction5-interaction21 yeardum* timedum*  , cluster(pnr) fe
eststo standard






#delimit ; 

coefplot (standard, mcolor(maroon) ciopts(color(maroon))) (callaway,  mcolor(blue) ciopts(color(blue)) rename(t_6_9=interaction1 t_7_9=interaction2 t_8_9=interaction3 t_9_10=interaction5 t_9_11=interaction6 t_9_12=interaction7 t_9_13=interaction8 t_9_14=interaction9 t_9_15=interaction10 ///
t_9_16=interaction11 t_9_17=interaction12 t_9_18=interaction13 t_9_19=interaction14 t_9_20=interaction15 t_9_21=interaction16 ///
t_9_22=interaction17 t_9_23=interaction18 t_9_24=interaction19 t_9_25=interaction20 t_9_26=interaction21 )),  omitted  vertical drop(yeardum* timedum* _cons) 



title("`var'")






xlabel(1 "-4" 2 " " 3 "-2" 4 " " 5 "0" 6 " " 7 "2" 8 " " 9 "4" 10 " " 11 "6" 12 " " 13 "8" 

14 " " 15 "10" 16 " " 17 "12" 18 " " 19 "14" 20 " " 21 "16", angle(0) nogrid labsize(medsmall))


ylabel(0 "0" 100000 "100" 200000 "200" 300000 "300" 400000 "400",nogrid angle(0) labsize(medsmall))






yscale(titlegap(*-3))


yline(0, lcolor(black))

xline(4, lcolor(black) lpattern(dash))

ytitle("Wealth", size(medium))

xtitle("Years", size(medsmall))

title("")


graphregion(fcolor(white)) bgcolor(white) scheme(s1color)

name(formue, replace)


;


#delimit cr



drop outcome zero_lead1 pre post 



}




* Secured Debt



local depvar1 "mortgage_real"




foreach var of varlist `depvar1'{


gen outcome=`var'



gen pre=0

gen post=0

replace pre=1 if (outcome~=. & time<1)

replace post=1 if (outcome~=. & time>0)



gen zero_lead1=0

preserve
keep if pyear>=1988
csdid outcome i.pyear, long2 ivar(pnr) time(time) gvar(treatment_year) 

estat event, window(-4,16)


eststo callaway

coefplot callaway, vertical


restore 
xtset pnr aar





xtreg outcome interaction1 interaction2 interaction3 zero_lead1 interaction5-interaction21 yeardum* timedum* if pyear>=1988 , cluster(pnr) fe
eststo standard









#delimit ; 

coefplot (standard, mcolor(maroon) ciopts(color(maroon))) (callaway,  mcolor(blue) ciopts(color(blue)) rename(t_6_9=interaction1 t_7_9=interaction2 t_8_9=interaction3 t_9_10=interaction5 t_9_11=interaction6 t_9_12=interaction7 t_9_13=interaction8 t_9_14=interaction9 t_9_15=interaction10 ///
t_9_16=interaction11 t_9_17=interaction12 t_9_18=interaction13 t_9_19=interaction14 t_9_20=interaction15 t_9_21=interaction16 ///
t_9_22=interaction17 t_9_23=interaction18 t_9_24=interaction19 t_9_25=interaction20 t_9_26=interaction21 )),  omitted  vertical drop(yeardum* timedum* _cons) 



title("`var'")






xlabel(1 "-4" 2 " " 3 "-2" 4 " " 5 "0" 6 " " 7 "2" 8 " " 9 "4" 10 " " 11 "6" 12 " " 13 "8" 

14 " " 15 "10" 16 " " 17 "12" 18 " " 19 "14" 20 " " 21 "16", angle(0) nogrid labsize(medsmall))


ylabel(0 "0" 100000 "100" 200000 "200" 300000 "300",nogrid angle(0) labsize(medsmall))







yscale(titlegap(*-3))


yline(0, lcolor(black))

xline(4, lcolor(black) lpattern(dash))

ytitle("Secured Debt", size(medium))

xtitle("Years", size(medsmall))

title("")


graphregion(fcolor(white)) bgcolor(white) scheme(s1color)

name(secured, replace)


;


#delimit cr



drop outcome zero_lead1 pre post 



}



* Unsecured Debt




local depvar1 "bankgaeld_real"




foreach var of varlist `depvar1'{


gen outcome=`var'



gen pre=0

gen post=0

replace pre=1 if (outcome~=. & time<1)

replace post=1 if (outcome~=. & time>0)



gen zero_lead1=0

preserve
 keep if pyear>=1991

csdid outcome i.pyear , long2 ivar(pnr) time(time) gvar(treatment_year)

estat event, window(-4,16)


eststo callaway

coefplot callaway, vertical

restore
xtset pnr aar





xtreg outcome interaction1 interaction2 interaction3 zero_lead1 interaction5-interaction21 yeardum* timedum*  if pyear>=1991, cluster(pnr) fe
eststo standard









#delimit ; 

coefplot (standard, mcolor(maroon) ciopts(color(maroon))) (callaway,  mcolor(blue) ciopts(color(blue)) rename(t_6_9=interaction1 t_7_9=interaction2 t_8_9=interaction3 t_9_10=interaction5 t_9_11=interaction6 t_9_12=interaction7 t_9_13=interaction8 t_9_14=interaction9 t_9_15=interaction10 ///
t_9_16=interaction11 t_9_17=interaction12 t_9_18=interaction13 t_9_19=interaction14 t_9_20=interaction15 t_9_21=interaction16 ///
t_9_22=interaction17 t_9_23=interaction18 t_9_24=interaction19 t_9_25=interaction20 t_9_26=interaction21 )),  omitted  vertical drop(yeardum* timedum* _cons) 



title("`var'")






xlabel(1 "-4" 2 " " 3 "-2" 4 " " 5 "0" 6 " " 7 "2" 8 " " 9 "4" 10 " " 11 "6" 12 " " 13 "8" 

14 " " 15 "10" 16 " " 17 "12" 18 " " 19 "14" 20 " " 21 "16", angle(0) nogrid labsize(medsmall))


ylabel(0 "0" -100000 "-100" -200000 "-200" -300000 "-300",nogrid angle(0) labsize(medsmall))







yscale(titlegap(*-3))


yline(0, lcolor(black))

xline(4, lcolor(black) lpattern(dash))

ytitle("Unsecured Debt", size(medium))

xtitle("Years", size(medsmall))

title("")


graphregion(fcolor(white)) bgcolor(white) scheme(s1color)

name(unsecured, replace)


;


#delimit cr



drop outcome zero_lead1 pre post 



}


* Graph combine

grc1leg earnings employment assets formue unsecured secured, graphregion(fcolor(white)) scheme(s1color) cols(2) rows(3) imargin(small) legendfrom(earnings)


graph save event_panel_callaway, replace

graph export event_panel_callaway.pdf, replace


